home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / Softshoe / Lisa's Portable Parts / BitArray / Bits.h < prev   
Encoding:
Text File  |  2000-06-23  |  1.3 KB  |  45 lines

  1. // Bits.h
  2.  
  3. #ifndef Bits_h
  4. #define Bits_h
  5.  
  6. #ifndef Integers_h
  7. #include "Integers.h"
  8. #endif
  9.  
  10. class Bits
  11.   {
  12.     private:
  13.         static const uint8 count[ maxuint8 + 1 ];
  14.         static const uint8 firstZero[ maxuint8 + 1 ];
  15.         static const uint8 lastZero[ maxuint8 + 1 ];
  16.         static const uint8 reverse[ maxuint8 + 1 ];
  17.     
  18.     public:
  19.         static uint32 Count( uint8 n )            { return count[n]; }
  20.         static uint32 Count( uint16 n );
  21.         static uint32 Count( uint32 n );
  22.  
  23.         static uint32 FirstZero( uint8 n )        { return firstZero[n]; }
  24.         static uint32 FirstZero( uint16 n );
  25.         static uint32 FirstZero( uint32 n );
  26.  
  27.         static uint32 LastZero( uint8 n )        { return lastZero[n]; }
  28.         static uint32 LastZero( uint16 n );
  29.         static uint32 LastZero( uint32 n );
  30.  
  31.         static uint32 FirstOne( uint8 n )        { return FirstZero( uint8(~n) ); }
  32.         static uint32 FirstOne( uint16 n )        { return FirstZero( uint16(~n) ); }
  33.         static uint32 FirstOne( uint32 n )        { return FirstZero( uint32(~n) ); }
  34.  
  35.         static uint32 LastOne( uint8 n )            { return LastZero( uint8(~n) ); }
  36.         static uint32 LastOne( uint16 n )        { return LastZero( uint16(~n) ); }
  37.         static uint32 LastOne( uint32 n )        { return LastZero( uint32(~n) ); }
  38.  
  39.         static uint8 Reverse( uint8 n )            { return reverse[n]; }
  40.         static uint16 Reverse( uint16 n );
  41.         static uint32 Reverse( uint32 n );
  42.   };
  43.  
  44. #endif
  45.